<?php

namespace app\api\controller;
use app\common\controller\Api;
use think\db;
/**
 * 日历相关
 */
class Date extends Api{


    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['test2'];



    public function getdatelist(){

        $date=$this->request->param('dates');
        $types=$this->request->param('types');


        $mas=$ma=date('Y-m').'-1';



        $w=date('N',strtotime($ma)); //第一天是礼拜几

        $allday= date("t",strtotime($ma));  //本月多少天

        $star=0;

        if ($w==7){
            $star=0;
        }else{

            $star=$w;
        }


        $arr=[];
        $all=$star+$allday;

        $newday=date('Y-m-',strtotime($ma));

        for ($a=1;$a<=$all;$a++){

            if ($a>$star){
                $arr[]=$newday.($a-$star>=10?$a-$star:'0'.($a-$star));
            }else{
                $arr[]='';
            }

        }


        $arrayb=[];



        foreach ($arr as $key=>$value){


            if ($star>$key){

                $int=intval($star)-intval($key);

                $strs=strtotime($ma)-($int*86400);


                $array['date']=date('Y-m-d',$strs);
                $array['dates']=date('d',$strs);
                $array['today']=0;
                $array['worker']=0;

            }else{

                $array['date']=$value;
                $array['today']=0;
                if ($array['date']==date('Y-m-d')){
                    $array['today']=1;
                }

                $array['dates']=substr($array['date'],-2);
                $array['worker']=1;

            }




            $arrayb[]=$array;
        }

        $y=date('Y',strtotime($mas)); //本年
        $m= getmbym(date('m',strtotime($mas))); //本月

        $this->success('请求成功',['y'=>$y,'m'=>$m,'list'=>$arrayb]);

    }



}



